package com.zhukaoguan.boot11.mapper;

import com.zhukaoguan.boot11.entity.News;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Mapper
public interface NewsMapper {
    @Select("select *from news where id=#{id}")
    List<News> selectById(int id);
    @Select("select id,title,intro from news")
    List<News> select();
    @Select("select *from news where intro like concat('%',#{kw},'%')")
    List<News> selectLike( String kw);
    @Delete("delete from news where id =#{id}")
    void delete(int id);
    @Insert("insert into news values(null,#{title},#{comtent},#{intro},#{created})")
    int insert(News news);
    @Select("select * from news order by created desc limit 0,3")
    List<News> limit();
    @Select("select *from news where intro like concat('%',#{kw},'%') or title like concat('%',#{kw},'%') ")
    List<News> byLike(String kw);
}
